package com.homework.T3;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;

/**
 * @author xiyu
 * @version 1.0
 * @date 2025/4/2 18:11
 * @description
 */
public class Test {
    public static void main(String[] args) {
        LinkedList<Worker> workers = new LinkedList<>();
        workers.add(new Worker("张3",18,3000));
        workers.add(new Worker("李4",25,3500));
        workers.add(new Worker("王5",22,3200));

        int index = -1;
        for (int i = 0; i < workers.size(); i++) {
            if (workers.get(i).getName().equals("李4")){
                index = i;
            }
        }
        workers.add(index,new Worker("赵6",24,3300));
        workers.removeLast();

        for (Worker worker : workers) {
            System.out.println(worker);
        }

        System.out.println("-------------------------");
        Iterator<Worker> it = workers.iterator();
        while (it.hasNext()) {
            Worker worker = it.next();
            work(worker);
        }

    }

    public static void work(Worker worker){
        System.out.println(worker.getName()+"在工作");
    }

}
